package com.pz.cloud.framework.material.model;

import com.pz.cloud.framework.business.material.entity.Material;
import com.pz.cloud.framework.business.material.service.IMaterialService;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.model.BaseImportModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 场地物资导入
 * @author mzz
 */
@Component
@Slf4j
public class MaterialImportModel extends BaseImportModel<Material> {

    @Autowired
    private IMaterialService materialService;

    /**
     * 获取导入模板文件
     * @return
     */
    @Override
    protected  String getTemplateFilePath(){
        String path = "excelTemplate/import/material.xlsx";
        return path;
    }

    @Override
    protected ImportValidetor validateEmptyField() {
        ImportValidetor importValidetor = ImportValidetor.instanec().addValidate("type", "类型")
                .addValidate("name","名称").addValidate("count", "数量")
                .addValidate("status", "状态");
        return importValidetor;
    }

    /**
     * 保存导入的数据
     */
    @Override
    public void saveData(Material data){
        materialService.save(data);
    }


    /**
     * 导入模板名称
     * @return
     */
    @Override
    public String getDemoFileName(){
        return "场地物资导入模板";
    }

}
